<?php

/**
 * +------------------------------------------------------------+
 * @category IndexAction
 * +------------------------------------------------------------+
 * 使用及关注药物
 * +------------------------------------------------------------+
 *
 * @author funwee@qq.com
 * @copyright http://www.suncco.com 2013
 * @version 1.0
 *
 * Modified at : 2013-10-22 上午10:51:44
 *
 */
class IndexAction extends Action {

    function index() {
        $categoryList = D('GroupCategory')->select();
        $user = D('User')->find($this->mid);

        $this->assign('categoryList', $categoryList);
        $this->display();
    }

    function add() {
        $categoryid = $_POST['categoryid'];
        $name = $_POST['name'];

        if ($this->isAjax()) {
            if (!$name) {
                $this->ajaxReturn(null, '药物名称不能为空！', 0);
            }
            //		dump($categoryid);exit;
            $model = D('MedicineTemp');
            $data['categoryid'] = $categoryid;
            $data['intime'] = time();
            $data['audit'] = 0;
            $data['uid'] = $this->mid;
            $data['name'] = $name;

            if (false !== $model->add($data)) {
                $this->ajaxReturn(null, '添加成功，请耐心等待管理员审核。', 1);
            } else {
                $this->ajaxReturn(null, '数据连接失败，请稍后再试。', 0);
            }
        }

        $this->display();
    }
}

?>